home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 2
/
Aminet AMIGA CDROM (1994)(Walnut Creek)[Feb 1994][W.O. 44790-1].iso
/
Aminet
/
gfx
/
misc
/
lise20.lha
/
lise2.0
/
mdl
/
src
/
skeletton.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-03-31
|
7KB
|
275 lines
/**---------------------------------------------------------------------
***
*** file: skeletton.c
***
*** project: skeletton for c-programs using procedural intuition access
*** ADD YOUR OWN ROUTINES AS SHOWN IN THE ROUTINE main(argc,argv)
*** AT THE END OF THIS FILE
***
*** (c) 1990 Rainer Kowallik
***
***-------------------------------------------------------------------*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <exec/types.h>
#include <libraries/dos.h>
#include <libraries/dosextens.h>
#include <intuition/intuition.h>
#include <workbench/workbench.h>
#include <workbench/startup.h>
#include <workbench/icon.h>
#include <mdllib.h>
char fs1_string[80]; /* user variable !!!!!!!! */
int scale_1;
int toggle_1;
/* ---------------------------------------------
User Callback functions
--------------------------------------------- */
void show_scale()
{
char s[80];
sprintf(s,"scale is %d\n",scale_1);
Help(s);
}
void show_toggle()
{
char s[80];
sprintf(s,"flag is %d\n",toggle_1);
Help(s);
}
void setscale()
{
scale_1 = scale_1 * 2;
}
void settoggle()
{
toggle_1 = toggle_1 ^ 1;
}
void new_pointer()
{
set_new_pointer();
}
void old_pointer()
{
set_old_pointer();
}
void password()
{
char s[80],s1[80];
StringBox("enter password",s);
sprintf(s1,"you entered %s\n",s);
Help(s1);
}
void showrequest()
{
int n;
n = RequestYesNo("you have the coice");
if(n) Help("You selected YES\n");
else Help("You selected NO\n");
}
void showfsel()
{
char *s;
s = (char *) malloc(200);
FileSelect("File Select",s);
strcat(s,"\n");
Help(s);
free(s);
}
void whoami()
{
char s[512];
strcpy(s,"Rainer Kowallik\nEisackstr. 14\n1000 Berlin 62\n");
strcat(s,"Tel (030) 855 866 5\n\nBorn in 1962\n");
strcat(s,"height 172 cm, weight 62 kg\n");
strcat(s,"nice looking, not yet married\n");
strcat(s,"graduated physicist working at HMI Berlin.\n");
strcat(s,"I like (in this order)\n");
strcat(s,"women, classic music, computers\n");
strcat(s,"playing violin and good physics");
Help(s);
}
void whatfor()
{
char s[512];
strcpy(s,"This is only a demonstration\n");
strcat(s,"of what you can do with the\n");
strcat(s,"SKELETTON program for\n");
strcat(s,"procedural intuition access\n");
strcat(s,"Please read the documentation\n");
strcat(s,"SKELETTON.DOC\n");
Help(s);
}
void congratu()
{
char s[80];
strcpy(s,"congratulation\n");
Help(s);
}
void fs1()
{
char s[80];
sprintf(s,"you selected %s\n",fs1_string);
Help(s);
}
/* **********************************************************************
You first have to write your call back routines, which are called
when a menu point is selected, or a push button is pressed.
Then you can add your functions to the intuition list at the main() routine
using:
add_item(x-pos, y-pos,TYPE,"text",opt1 , opt2);
Some items need a callback routine, some need a global variable to write to.
These you can now add with:
fn_command[fn_number] = (void *)CallbackRoutine;
var_value[fn_number] = &GlobalVariable;
Now you have to increment the fn_number.
Available values for TYPE are:
Identifier needs comment
NEW_MENU nothing main point of menue, displayed in menu bar
MENU Callback adds menu point under actual main point
PUSH Callback adds a push button
TOGGLE Global variable adds a toggle button
SCALEX Global variable adds a scaler in x-direction
opt1 = lowest value
opt2 = highest value
SCALEY Global variable adds a scaler in y-direction
SELECTION Global variable + Callback
adds a selector box with predefined items
FILE_SELECT Global variable + Callback
adds a file selector box
STRING Global variable + Callback
adds a string box
INTEGER Global variable + Callback
adds an integer box
FLOAT Global variable + Callback
adds a floatingpoint box
******************************************************************** */
main(argc,argv)
unsigned int argc;
char *argv[];
{
/* -------------------------------------------------------------------------
IF YOU NEED ACCESS TO THE WORK BENCH MESSAGES, YOU MAY USE THIS FRAGMENT
FROM THE ORIGINAL MDL
if(argc > 1) {
strcpy(mdlfile,argv[1]);
} else {
IconBase = (struct IconBase *) OpenLibrary("icon.library", 0L);
Arg = WBenchMsg->sm_ArgList; Arg++;
CurrentDir(Arg->wa_Lock);
strcpy(mdlfile,Arg->wa_Name);
}
------------------------------------------------------------------------- */
/* --- window geometry and name */
my_new_window = init_window(350,150,"skeletton test",0,1);
/* ----- initializing menus and requesters */
add_item(-1,-1,NEW_MENU,"project",0,0);
fn_number++;
add_item(-1,-1,MENU,"show scale",0,0);
fn_command[fn_number] = (void *)show_scale;
fn_number++;
add_item(-1,-1,MENU,"show toggle",0,0);
fn_command[fn_number] = (void *)show_toggle;
fn_number++;
add_item(-1,-1,MENU,"new pointer",0,0);
fn_command[fn_number] = (void *)new_pointer;
fn_number++;
add_item(-1,-1,MENU,"old pointer",0,0);
fn_command[fn_number] = (void *)old_pointer;
fn_number++;
add_item(-1,-1,MENU,"password",0,0);
fn_command[fn_number] = (void *)password;
fn_number++;
add_item(-1,-1,MENU,"Request Yes/No",0,0);
fn_command[fn_number] = (void *)showrequest;
fn_number++;
add_item(-1,-1,MENU,"File Select",0,0);
fn_command[fn_number] = (void *)showfsel;
fn_number++;
add_item(-1,-1,MENU,"set toggle",0,0);
fn_command[fn_number] = (void *)settoggle;
fn_number++;
add_item(-1,-1,MENU,"set scale",0,0);
fn_command[fn_number] = (void *)setscale;
fn_number++;
add_item(-1,-1,NEW_MENU,"help",0,0);
fn_number++;
add_item(-1,-1,MENU,"whoami",0,0);
fn_command[fn_number] = (void *)whoami;
fn_number++;
add_item(-1,-1,MENU,"whatfor",0,0);
fn_command[fn_number] = (void *)whatfor;
fn_number++;
add_item(200,15,TOGGLE,"toggle here",0,0);
var_value[fn_number] = &toggle_1;
fn_number++;
add_item(200,40,SCALEX,"moveme",0,100);
var_value[fn_number] = &scale_1;
fn_number++;
add_item(220,80,PUSH,"PUSH HERE",0,0);
fn_command[fn_number] = (void *)congratu;
fn_number++;
add_item(10,15,FILE_SELECT,"example",0,0);
var_value[fn_number] = (int *)&fs1_string;
fn_command[fn_number] = (void *)fs1;
fn_number++;
my_window = (struct Window *) OpenWindow( my_new_window );
SetMenuStrip( my_window, menu_bar );
if(my_window == NULL)
{
close_gfx(NULL);
exit(0);
}
fin_flg = FALSE;
MainLoop(my_window);
exit(0);
}